﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using System.IO;

namespace Snefru.Managers
{
    public class XmlOperationManager<T>
    {
        public virtual void Save(T parameters, string xmlPath)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            StreamWriter writer = new StreamWriter(xmlPath);
            serializer.Serialize(writer, parameters);
            writer.Close();
            writer.Dispose();
        }
        public virtual T GetDetail(string xmlPath)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            StreamReader reader = new StreamReader(xmlPath);
            T item = (T)serializer.Deserialize(reader);
            reader.Close();
            reader.Dispose();
            return item;
        }
    }    
}
